//
//  KeychainItem.h
//  MailDelivery
//
//  Created by Dante Palacios on 9/24/09.
//  Copyright 2009 Dante Palacios. All rights reserved.
//

/*!
 @header KeychainItem.h
 @abstract The methods listed here may disappear or change their names without prior notice. For more information, contact palacios.dante\@gmail.com.
 */

#import <Foundation/Foundation.h>
#import <Security/Security.h>

/*!
 @class KeychainItem
 @abstract Class that representes a keychain item.
 @discussion Represents the kind of keychain item that this framework use. The properties change some of their names in order to avoid confusions, specially with concepts like delivery account and their properties.
 */

@interface KeychainItem : NSObject {
@private;
	SecKeychainItemRef _keychainItemRef;
	NSString *_hostName;
	NSString *_userName;
	NSString *_password;
}

/*!
 @property keychainItemRef
 @abstract the <tt>keychainItemRef</tt>.
 */

@property (assign) SecKeychainItemRef keychainItemRef;

/*!
 @property hostName
 @abstract the <tt>kSecServerItemAttr</tt> attribute.
 */

@property (copy) NSString *hostName;

/*!
 @property userName
 @abstract the <tt>kSecAccountItemAttr</tt> attribute.
 */

@property (copy) NSString *userName;

/*!
 @property password
 @abstract the password for the keychain item.
 */

@property (copy) NSString *password;

@end

/*!
 @function ModifyKeychainItemRef
 @abstract Used to modify the attributes of an <tt>keychainItemRef</tt>.
 @discussion If you need to modify more attributes, you may want to try this funtion, or use you own;
 @param itemRef
 the <tt>keychainItemRef</tt> to modify.
 @param itemAttribute
 the <tt>SecItemAttr</tt> attribute to modify.
 @param value
 the new value for the <tt>SecItemAttr</tt>.
 */

OSStatus ModifyKeychainItemRef(SecKeychainItemRef itemRef, SecItemAttr itemAttribute, NSString *value);